
const searchProjectForm = [
  { label: '', width: '140px', value: 'btnOperation', type: 'slot' },
	{ label: '项目名称', value: 'query', type: 'input', width: '220px' },
  { label: '状态', value: 'status', type: 'select', width: '124px' , option: 'sysRoleStatus'},
	{ label: '', width: '200px', value: 'btnSearch', type: 'slot' }
];

const projectTables = [ // 表格数据
  { label: '项目ID', value: 'id', width:100},
  { label: '项目编号', value: 'prono' },
  { label: '项目名称', value: 'name' },
  { label: '隶属部门', value: 'org' },
  { label: '业务服务', value: 'service' },
  { label: '状态', type: 'slot', value: 'status', width:100},
  { label: '项管名称', value:'user'},
  { label: '备注信息', value: 'desc'},
  { label: '更新时间', value: 'stime'}
];

const fieldListProject = [ // 新增弹出数据
  { label: '项目编号', value: 'prono', type: 'input', width: '270px'},
  { label: '隶属部门', value: 'deptid', type:'select', width: '300px',  option: 'sysOrg', remote:true, loading: true, store:"dictSrv/sysOrg", className:''},
  { label: '项管名称', value: 'manager', type:'select', width: '300px',  option: 'sysUser', remote:true, loading: true, store:"dictSrv/sysUser", className:''},
  { label: '项目名称', value: 'name', type: 'input', width: '400px'},
  { label: 'Git地址', value: 'git', type: 'input', width: '400px'},
  { label: '业务服务', value: 'service', type: 'input', width: '400px'},
  { label: '状态', value: 'status', type: 'select', width: '200px', option: 'sysRoleStatus', filterable: true},
  { label: '备注信息', value: 'desc', type:'textarea', width: '400px'},
];

const rulesProject = {
  prono: [{ required: true, message: '请输入项目编号', trigger: 'change' }],
  desc: [{ required: true, message: '请输入备注', trigger: 'change' }],
  status: [{ required: true, message: '请选择状态', trigger: 'change' }],
  deptid: [{ required: true, message: '请选择隶属部门', trigger: 'change' }],
  manager: [{ required: true, message: '请选择项管名称', trigger: 'change' }],
  git: [{ required: true, message: '请输入项目Git地址', trigger: 'change' }],
  name: [{ required: true, message: '请输入项目名称', trigger: 'change' }]
};

const searchUserForm = [
  { label: '', width: '140px', value: 'btnOperation', type: 'slot' },
  { label: '角色', value: 'role', type: 'select', width: '160px' , option: 'prjOfficerRole'},
  { label: '', width: '100px', value: 'btnSearch', type: 'slot' }
];

const userTables = [ // 表格数据
  { label: 'ID编号', value: 'id' ,width:100},
  { label: '账号', value: 'user' },
  { label: '隶属部门', value: 'org' },
  { label: '项目角色', type: 'slot', value: 'role', width:100},
  { label: '过期时间', value: 'expire' }
];

const fieldListUser = [ // 新增弹出数据
  { label: '账号', value: 'userid', type:'select', width: '380px',  option: 'sysUser', remote:true, loading: true, store:"dictSrv/sysUser", className:''},
  { label: '关联项目', value: 'projectid', type:'select', width: '380px',  option: 'sysProject', remote:true, loading: true, disabled:true, store:"dictSrv/sysProject", className:''},
  { label: '角色', value: 'role', type: 'select', width: '260px', option: 'prjOfficerRole', filterable: true},
  { label: '过期时间', value: 'expire', type:'date', width: '260px', dateType:'datetime', format:"yyyy-MM-dd HH:mm:ss"},
];

const rulesUser = {
  userid: [{ required: true, message: '请选择关联用户', trigger: 'change' }],
  role: [{ required: true, message: '请选择角色', trigger: 'change' }],
  projectid: [{ required: true, message: '请选择关联项目', trigger: 'change' }],
  expire: [{ required: true, message: '请设置过期时间', trigger: 'change' }],
};


const searchServerForm = [
  { label: '', width: '740px', value: 'btnOperation', type: 'slot' },
  { label: '服务器名称', value: 'query', type: 'input', width: '210px' },
  { label: '运行环境', value: 'role', type: 'select', width: '200px' , option: 'prjServerRole'},
  { label: '', width: '180px', value: 'btnSearch', type: 'slot' }
];

const serverTables = [ // 表格数据
  { label: 'ID编号', value: 'id' ,width:100},
  { label: '项目名称', value: 'project' },
  { label: '服务器名称', value: 'title' },
  { label: 'rsyncd服务', value: 'rsyncd' },
  { label: '服务模块', value: 'rsync_service' },
  { label: '密码文件', value: 'rsync_password' },
  { label: 'rsyncd状态', value: 'sync_status' },
  { label: '服务器描述', value: 'desc' },
  { label: '运维管理员', value: 'operator' },
  { label: '运行环境', type: 'slot', value: 'role', width:100},
  { label: '操作IP', value: 'ip' },  
  { label: '更新时间', value: 'stime' }
];

const fieldListServer = [ // 新增弹出数据
  { label: '关联项目', value: 'projectid', type:'select', width: '380px',  option: 'sysProject', disabled:true, remote:true, loading: true, store:"dictSrv/sysProject", className:''},
  { label: '服务器名称', value: 'title', type: 'input', width: '380px'},
  { label: 'rsyncd服务IP', value: 'rsync_ip', type:'input', width: '380px'},
  { label: 'rsyncd服务端口', value: 'rsync_port', type:'input', width: '380px'},
  { label: 'rsyncd服务模块', value: 'rsync_service', type:'input', width: '380px'},
  { label: 'rsyncd服务连线用户', value: 'rsync_user', type:'input', width: '380px'},
  { label: 'rsyncd服务连线密码文件', value: 'rsync_password', type:'input', width: '380px', className:''},
  { label: '运行环境', value: 'role', type: 'select', width: '300px', option: 'prjServerRole', filterable: true, className:''},
  { label: '服务器描述', value: 'desc', type:'textarea', width: '460px'},
];

const rulesServer = {
  projectid: [{ required: true, message: '请选择关联项目', trigger: 'change' }],
  title: [{ required: true, message: '请输入服务器名称', trigger: 'change' }],
  rsync_ip: [{ required: true, message: '请输入rsyncd服务IP', trigger: 'change' }],
  rsync_port: [{ required: true, message: '请输入rsyncd服务端口', trigger: 'change' }],
  rsync_service: [{ required: true, message: '请输入rsyncd服务模块', trigger: 'change' }],
  rsync_user: [{ required: true, message: '请输入rsyncd服务连线用户', trigger: 'change' }],
  rsync_password: [{ required: true, message: '请输入rsyncd服务连线密码文件', trigger: 'change' }],
  role: [{ required: true, message: '请选择运行环境', trigger: 'change' }],
  status: [{ required: true, message: '请选择状态', trigger: 'change' }],
  desc: [{ required: true, message: '请输入服务器备注信息', trigger: 'change' }]
};

const fieldDataProject = (data)=>{
  var dataset = {};
  for (var idx = 0; idx < fieldListProject.length; idx++) {
    var ckey  = fieldListProject[idx].value;
    dataset[ckey] = (data)? data[ckey]:'';
  }
  dataset.id = (data && data.id)? data.id:0;
  return dataset;
}

const fieldDataUser = (data)=>{
  var dataset = {};
  for (var idx = 0; idx < fieldListUser.length; idx++) {
    var ckey  = fieldListUser[idx].value;
    dataset[ckey] = (data)? data[ckey]:'';
  }
  dataset.id = (data && data.id)? data.id:0;
  return dataset;
}

const fieldDataServer = (data)=>{
  var dataset = {};
  for (var idx = 0; idx < fieldListServer.length; idx++) {
    var ckey  = fieldListServer[idx].value;
    dataset[ckey] = (data)? data[ckey]:'';
  }
  dataset.id = (data && data.id)? data.id:0;
  return dataset;
}

export default {
  searchProjectForm,searchUserForm,searchServerForm,fieldListUser,rulesUser,fieldDataUser,
  rulesProject,fieldDataProject,fieldListProject,projectTables,userTables,serverTables,rulesServer,fieldListServer,fieldDataServer
};